import{mt as e,ut as t}from"./B603vO-13smUKN.js";import{b as n,k as r,mt as i,vn as a,xt as o}from"./CIxmKYxc4tZcJF.js";import{l as s}from"./CrVzHk_r1oIxh7.js";var c=t(`drag-util`);function l(e,t){for(;e!=null;){if(t&&(!t?.contains(e)||t.isSameNode(e)))return!1;if(e.dataset?.noscroll===`true`)return c(`exit noscroll`),!0;if(e.tagName===`BODY`)return c(`exit body`),!0;let{overflow:n}=window.getComputedStyle(e);if(n.split(` `).some(e=>e===`auto`||e===`scroll`))return c(`exit scroll`,e.scrollTop,n),!0;e=e.parentElement}return!1}var u=r({__name:`oui-draggable`,props:{onlyTouch:{type:Boolean},cancelEvents:{type:Boolean}},emits:[`moveStart`,`move`,`moveEnd`],setup(r,{emit:c}){let u=r,d=c,f=t(`oui-draggable`),p=a(),m=0,h=!1,g=!1,_=0,v=0,y=0,b=0,x=0,S=0,C;function w(t){let{pageX:n,pageY:r}=t?.touches?.[0]??t;x=n-y,S=r-b,y=n,b=r;let i=_-n,a=v-r,o={startX:_,startY:v,pageX:n,pageY:r,deltaX:x,deltaY:S,moveX:i,moveY:a,timeMS:e()-m};return f(`event`,o),C=o,o}function T(e){u.cancelEvents&&(e?.stopPropagation(),e?.preventDefault())}function E(t){if(t.target&&p.value&&l(t.target,p.value))return;f(`down`);let{pageX:n,pageY:r}=t?.touches?.[0]??t;return m=e(),h=!0,_=n,v=r,y=n,b=r,d(`moveStart`,w(t)),M(),T(t)}function D(e){if(f(`move`,h,e),h)return d(`move`,w(e)),T(e)}function O(t){return f(`up`),h=!1,C&&(C.timeMS=e()-m),d(`moveEnd`,C??w(t)),C=void 0,N(),T(t)}function k(){g=!g}let A={passive:!1};u.onlyTouch||(s(p,`mousedown`,E),s(p,`dblclick`,k)),s(p,`touchstart`,E);let j=[];function M(){j=[s(document,`touchmove`,D,A),s(document,`touchend`,O)],u.onlyTouch||j.push(s(document,`mousemove`,D,A),s(document,`mouseup`,O))}function N(){j.forEach(e=>e()),j=[]}return(e,t)=>(i(),n(`div`,{ref_key:`el`,ref:p,"data-noscroll":`true`},[o(e.$slots,`default`)],512))}});export{u as t};